@use "../variables" as *;
@use "sass:color";

.farm-designer {
  position: relative;
  height: 100vh;
  overflow: scroll;
  scrollbar-width: none;
  .garden-map-legend {
    @media screen and (max-width: $mobile_max_width) {
      &.panel-open,
      &.short-panel {
        display: none;
      }
      &.panel-closed-mobile,
      &.panel-closed {
        top: 13rem;
      }
    }
  }
}

.farm-designer-map {
  display: inline-block;
  min-width: 100%;
  padding: 9rem 2rem 2rem 2rem;
  height: 100%;
  overflow: visible;
  transition: 0.3s ease;
  &.panel-open {
    padding: 9rem 2rem 2rem 47.5rem;
    @media screen and (max-width: $mobile_max_width) {
      padding: 18rem 2rem 2rem 47.5rem;
    }
  }
  &.panel-closed-mobile {
    padding: 16rem 1rem 1rem 1rem;
  }
  &.short-panel {
    padding: 35rem 1rem 1rem;
  }
  &::-webkit-scrollbar {
    display: none;
  }
}

.drop-area {
  svg {
    width: 100%;
    height: 100%;
    overflow: visible;
    text {
      pointer-events: none;
    }
    text::selection {
      background: none;
    }
  }
}

.drop-area-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.drop-area-background a {
  cursor: default !important;
}

.crop-drag-info-image {
  width: 7rem;
  height: 7rem;
  padding: 1rem;
}

.plant-catalog-image {
  width: 100%;
  background-position: center center !important;
  background-size: cover !important;
  background-color: $translucent;
  aspect-ratio: 3 / 2;
  border-radius: 5px;
  &.fallback-image {
    background-size: 50% !important;
    background-color: $translucent15 !important;
  }
}

.thin-search-wrapper {
  .spinner-container {
    position: absolute;
    top: 0;
    right: 0;
    width: 2rem;
    height: 2rem;
    padding: 0;
    margin-right: 1rem;
  }
  .text-input-wrapper {
    align-items: center;
    border-bottom: 1.5px solid var(--border-color);
    display: flex;
    padding: 0 0.75rem;
    i {
      font-size: 1.5rem;
    }
    .fa-search {
      cursor: default !important;
    }
    .fa-times {
      color: $medium_dark_red;
      font-size: 1.3rem;
      &:hover {
        color: $red;
      }
    }
    .point-sort-menu {
      width: 110px;
      label {
        margin-top: 0;
      }
      i {
        cursor: pointer;
        padding: 0.5rem;
        color: $medium_light_gray;
        &.selected {
          font-weight: bold;
          color: $dark_gray;
        }
      }
    }
    input {
      background: transparent;
      box-shadow: none !important;
      font-size: 1.4rem !important;
      color: inherit;
      &:active,
      &:focus {
        background: transparent !important;
      }
      &::-webkit-input-placeholder {
        color: $placeholder_gray;
      }
    }
  }
}

.panel-content {
  %panel-item-base {
    font-size: 1rem;
  }
  .group-search-item {
    grid-template-columns: 1fr auto!important;
  }
  .plant-search-item,
  .group-search-item,
  .curve-search-item {
    display: grid;
    gap: 1rem;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem 1rem;
    img {
      height: 3rem;
      width: 3rem;
    }
    &.quick-del {
      &:hover {
        background: color.adjust($red, $lightness: 10%) !important;
        &:after {
          content: "x";
          margin-left: 1rem;
          color: $darkest_red;
          font-weight: bold;
        }
      }
    }
  }
  .curve-search-item-name,
  .plant-search-item-name,
  .regimen-search-item-name,
  .saved-garden-search-item-name,
  .weed-search-item-name,
  .point-search-item-name {
    display: inline-block;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  .plant-search-item-age {
    @extend %panel-item-base;
  }
  .group-item-count {
    @extend %panel-item-base;
    padding-top: 0.6rem;
    line-height: 1rem;
  }
  .weed-search-item,
  .point-search-item {
    cursor: pointer;
    padding: 0.5rem 1rem;
    .saucer {
      display: inline-block;
      height: 3rem;
      width: 3rem;
      vertical-align: middle;
      margin-right: 0.25rem;
    }
    .quick-delete {
      display: inline;
      color: $dark_red;
      &.hovered {
        font-weight: bold;
      }
    }
  }
  .weed-search-item-info,
  .point-search-item-info {
    text-align: right;
    font-size: 1rem;
    padding-right: 1rem;
    line-height: 3rem;
    float: right;
  }
  .tool-search-item,
  .tool-slot-search-item {
    margin: 0 -1rem;
    padding: 0 1rem;
    cursor: pointer;
    .tool-svg,
    .tool-slot-search-item-icon {
      svg {
        vertical-align: middle;
      }
    }
    .tool-search-item-name,
    .tool-slot-search-item-name {
      margin-left: 0;
      p {
        font-size: 1.3rem;
      }
    }
    .tool-status,
    .tool-slot-position-info {
      padding: 0;
    }
    p {
      font-size: 1rem;
      line-height: 4rem;
      &.tool-status,
      &.tool-slot-position {
        min-width: 10rem;
        text-align: right;
      }
    }
  }
  .regimen-search-item {
    display: grid;
    gap: 1rem;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    cursor: pointer;
    height: 3.5rem;
    padding: 1rem;
    .regimen-search-item-name {
      font-size: 1.4rem;
    }
    .regimen-color {
      .color-picker {
        display: inline;
        .saucer {
          width: 1.2rem;
          height: 1.2rem;
        }
      }
    }
  }
  &.scrolled {
    box-shadow: inset 0 5px 10px rgba(0, 0, 0, 0.1);
  }
}

.hovered-plant-copy {
  cursor: pointer;
  transform-origin: center;
  transform-box: fill-box;
}

.plant-link-wrapper {
  &.is-chosen-true.is-editing-true {
    cursor: -webkit-grab !important;
    &:active {
      cursor: -webkit-grabbing !important;
    }
  }
}

.weed-indicator.is-chosen-true,
.plant-indicator.is-chosen-true {
  transform-origin: center;
  transform-box: fill-box;
  &.animate {
    animation: plant-selection-pop 0.2s 1 cubic-bezier(0, 0, 0, 0.9), pulse-and-rotate 4s 0.2s infinite linear;
  }
}

.tool-slot-indicator {
  transform-origin: center;
  transform-box: fill-box;
  &.animate {
    animation: pulse-and-rotate 4s 0.2s infinite linear;
  }
}

.map-point {
  cursor: pointer !important;
  stroke-width: 2;
  stroke-opacity: 0.3;
  fill-opacity: 0.1;
  text {
    paint-order: stroke;
  }
  &.is-selected {
    .point-radius {
      transform-origin: center;
      transform-box: fill-box;
      &.animate {
        animation: dashed-rotate 4s infinite linear;
      }
    }
  }
}

.map-weed {
  cursor: pointer !important;
}

.weed-image,
.plant-image {
  transform-origin: bottom;
  transform-box: fill-box;
  &.animate {
    &.new {
      animation: plant-growth 0.25s cubic-bezier(0, 0, 0, 1.4);
    }
  }
}

.bug {
  z-index: 10;
  transform-origin: bottom;
  transform-box: fill-box;
  &.animate {
    animation: plant-growth 0.25s cubic-bezier(0, 0, 0, 1.4);
  }
  &.dead {
    z-index: 5;
    pointer-events: none;
  }
}

.soil-cloud {
  transform-origin: center;
  transform-box: fill-box;
  &.new {
    animation: soil-poof 0.5s cubic-bezier(0, 0, 0, 1);
  }
}

.spread {
  transform-origin: center;
  transform-box: fill-box;
  pointer-events: none;
  &.animate {
    animation: spread-pop 0.2s cubic-bezier(0, 0, 0, 1);
  }
}

.logs-layer {
  @keyframes capture-animation {
    0% {
      fill: rgba(255, 255, 240, 0.7);
      stroke: rgba(20, 190, 230, 0.7);
    }
    100% {
      fill: rgba(0, 0, 0, 0.02);
      stroke: rgba(0, 0, 0, 0.02);
    }
  }

  .img-full {
    width: 100%;
    height: 100%;
    stroke-opacity: 1;
    stroke-width: 4px;
    stroke: rgba(20, 190, 230, 0.7);
    fill: rgba(255, 255, 240, 0.7);
  }

  .capture,
  .scan {
    .img-scan {
      visibility: hidden;
    }
    &.animate {
      .img-full {
        animation: capture-animation 2s ease forwards;
      }
    }
  }

  .scan {
    .img-scan {
      visibility: visible;
      transform: translateX(25%);
      width: 8%;
      stroke-opacity: 0;
    }

    &.animate {
      @keyframes scan-animation {
        100% {
          transform: translate(95%, 0);
        }
      }

      .img-scan {
        transform: none;
        animation: scan-animation 3s linear alternate infinite;
      }
    }
  }
}

.zones-layer {
  [id*="zones-1D-"] {
    stroke: $black;
    stroke-width: 5;
  }
  [id*="zones-"] {
    opacity: 0.1;
    &.current {
      opacity: 0.25;
      fill: $white;
      stroke: $white;
    }
    &:hover {
      opacity: 0.15;
    }
  }
}

.virtual-bot-trail,
.virtual-peripherals {
  pointer-events: none;
}

.water-spray {
  &.animate {
    animation-duration: 3s;
    animation-iteration-count: infinite;
    animation-name: water-spray-animation;
    transform-origin: center;
    transform-box: fill-box;
    opacity: 0;
  }
}

.delay-1 {
  animation-delay: 1s;
}

.delay-2 {
  animation-delay: 2s;
}

@keyframes water-spray-animation {
  0% {
    transform: scale(0.7) rotate(0deg);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: scale(1.1) rotate(10deg);
    opacity: 0;
  }
}

.vacuum {
  &.animate {
    animation-duration: 3s;
    animation-iteration-count: infinite;
    animation-name: vacuum-animation;
    transform-origin: center;
    transform-box: fill-box;
    opacity: 0;
  }
}

@keyframes vacuum-animation {
  0% {
    transform: scale(1);
    opacity: 0;
  }
  100% {
    transform: scale(0);
    opacity: 1;
  }
}

.rotary {
  &.animate {
    animation-duration: 3s;
    animation-iteration-count: infinite;
    animation-name: rotary-animation;
    transform-origin: center;
    transform-box: fill-box;
    opacity: 0;
  }
}

@keyframes rotary-animation {
  0% {
    transform: scale(1);
    opacity: 0;
  }
  100% {
    transform: scale(0);
    opacity: 1;
  }
}

.garden-map-legend {
  position: absolute;
  top: 7.5rem;
  right: -155px;
  z-index: 3;
  transition: all 0.3s ease;
  &.active {
    transform: translateX(-165px);
  }
  .content {
    display: flex;
    flex-direction: row-reverse;
    gap: 1.25rem;
    .menu-content, .z-display {
      background-color: var(--main-bg);
      border-radius: 1rem;
      box-shadow: var(--box-shadow);
      backdrop-filter: var(--blur);
    }
    .menu-content {
      display: grid;
      max-width: 155px;
      padding: 1.25rem;
      gap: 0.75rem;
      justify-items: center;
      overflow: hidden;
      .zoom-buttons {
        display: flex;
        flex-direction: row-reverse;
        gap: 1rem;
        button {
          margin: auto;
        }
      }
    }
    .z-display {
      position: relative;
      padding: 2rem;
      padding-left: 3rem;
      label {
        position: absolute;
        top: 0.5rem;
        left: 44%;
      }
      .sliders {
        height: 98%;
        .bp6-slider {
          height: 100%;
          margin-left: 1rem;
        }
        .input-slider {
          pointer-events: none;
          .bp6-slider-handle {
            left: 3.8px;
            height: 8px;
            width: 9px;
            background: none;
            box-shadow: none;
            border: 1px solid $dark_gray;
            border-radius: 2px;
            .bp6-slider-label {
              margin-left: -6px;
              margin-top: -14px;
            }
          }
        }
        .data-slider {
          .bp6-start {
            height: 5px;
            &:first-of-type {
              display: unset;
            }
          }
          .bp6-slider-label {
            margin-left: -6rem;
            opacity: 1;
          }
        }
      }
    }
  }
  .toggle-buttons,
  .z-display-toggle {
    fieldset {
      display: flex;
      align-items: center;
      line-height: 2.75rem;
    }
    label {
      margin: 0;
      width: 100%;
    }
    button {
      margin: 0;
    }
  }
  .move-to-mode {
    display: none;
    @media screen and (max-width: $mobile_max_width) {
      display: block;
    }
  }
  .menu-pullout {
    position: absolute;
    left: -4.5rem;
    color: $off_white;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0px 1px 1px #555;
    font-size: 1.5rem;
    &.active {
      left: -4.5rem;
      transform: rotate(180deg);
      text-shadow: 1px 0px 0px #555;
      &:hover {
        left: -4.5rem;
        span {
          opacity: 0;
        }
      }
    }
    &:hover {
      left: -5rem;
      span {
        opacity: 1;
      }
    }
    span {
      position: absolute;
      top: 0.6rem;
      left: -4.6rem;
      transition-delay: 0.6s;
      transition: all 0.4s ease;
      opacity: 0;
    }
  }
}

.farmbot-origin {
  margin: auto;
  width: 120px;
  &.xy-swap {
    width: 60px;
    .quadrant {
      height: 48px;
    }
  }
  .quadrants {
    display: flex;
    flex-wrap: wrap;
    border: 1px solid var(--border-color);
  }
  .quadrant {
    display: inline-block;
    position: relative;
    background-image: linear-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 0, 0, 0.05) 1px, transparent 1px), linear-gradient(rgba(0, 0, 0, 0.05) 2px, transparent 2px), linear-gradient(90deg, rgba(0, 0, 0, 0.05) 2px, transparent 2px);
    background-size: 4px 4px, 4px 4px, 100px 100px, 100px 100px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    width: 50%;
    height: 24px;
    transition: all 0.2s ease-in-out;
    &:hover {
      background-color: rgba(0, 0, 0, 0.1);
    }
    &.selected {
      box-shadow: inset 0 0 8px var(--border-color);
    } // Quadrant 1
    &:nth-child(2) {
      &:before {
        top: 0;
        right: 0;
      }
      &:after {
        top: 8px;
        right: 16px;
      }
    } // Quadrant 2
    &:nth-child(1) {
      &:before {
        top: 0;
        left: 0;
      }
      &:after {
        top: 8px;
        left: 16px;
      }
    } // Quadrant 3
    &:nth-child(3) {
      &:before {
        left: 0;
        bottom: 0;
      }
      &:after {
        left: 16px;
        bottom: 8px;
      }
    } // Quadrant 4
    &:nth-child(4) {
      &:before {
        bottom: 0;
        right: 0;
      }
      &:after {
        bottom: 8px;
        right: 16px;
      }
    }
    &:before {
      content: "";
      position: absolute;
      background: $black;
      width: 8px;
      height: 8px;
      border-radius: 50%;
    }
    &:after {
      content: "";
      position: absolute;
      background: $green;
      width: 8px;
      height: 8px;
      border-radius: 50%;
    }
  }
}

.map-size-grid {
  grid-template-columns: auto 6rem !important;
}

.image-filter-menu {
  .fa {
    font-weight: bold;
  }
  .fa-caret-left,
  .fa-caret-right {
    font-size: 1.4rem;
  }
  .fa-step-backward,
  .fa-step-forward {
    font-size: 1rem;
  }
}

@media screen and (min-width: $mobile_max_width) {
  .farm-designer-panels.panel-closed ~ .three-d-garden .garden-bed-3d-model {
    animation: panel-hide-shift-3d 0.3s ease forwards;
  }
  .farm-designer-panels.panel-open ~ .three-d-garden .garden-bed-3d-model {
    animation: panel-show-shift-3d 0.3s ease forwards;
  }
}

@keyframes panel-show-shift-3d {
  0% {
    transform: translateX(-22.5rem);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes panel-hide-shift-3d {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-22.5rem);
  }
}

.three-d-map-toggle-menu {
  position: fixed;
  bottom: 0;
  right: 0;
  padding: 1rem;
  button {
    height: 3.5rem;
    width: 3.5rem;
    i {
      font-size: 1.5rem;
    }
    &.active {
      background-color: $blue !important;
    }
  }
  .three-d-map-toggle {
    padding: 0 1.5rem;
    background-color: var(--main-bg);
    backdrop-filter: var(--blur);
    border-radius: 0.5rem;
    box-shadow: var(--box-shadow);
    height: 3.5rem;
  }
}
